package com.linkage.bookshop.repository;

import java.util.List;
import java.util.Date;

import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;

import com.linkage.bookshop.model.*;

@Repository
public interface BookRepository {
	public List<Book> selectBooksByTypeId(@Param("typeId") int typeId,
			@Param("offset") int offset, @Param("rows") int rows,
			@Param("orderBy") String orderBy);

	public List<Book> selectBooksByKeyWord(@Param("keyWord") String keyWord,
			@Param("offset") int numPerPage, @Param("rows") int pageNum,
			@Param("orderBy") String orderBy);
	
	public List<Book> selectAllBooksOnsaleByTypeId(@Param("typeId") int typeId);
	
	public List<Book> selectAllBooksOnsaleByKeyWord(@Param("keyWord")String keyWord);
	
	public List<Book> selectAllBooksByTypeId(@Param("typeId") int typeId);
	
	public List<Book> selectAllBooksByKeyWord(@Param("keyWord") String keyWord);
	
	public List<Book> selectAllBooks();

	public Book selectBookDetail(int bookId);

	public void insertType(Booktype bookType);

	public List<Booktype> selectAllTypes();

	public void insertBook(Book book);

	public void updateBook(Book book);

	public void updateBookStatusOnsale(@Param("bookId") int bookId);

	public void updateBookStatusNotOnsale(@Param("bookId") int bookId);

	public Booktype selectBookTypeById(@Param("typeId") int typeId);

	public Booktype selectBookTypeByName(@Param("typeName") String typeName);

	// update
	public void updateOnsaleFlag(@Param("onsaleFlag") boolean b,
			@Param("bookId") int bookId);

	public void updateBookType(@Param("typeId") int typeId,
			@Param("bookId") int bookId);

	public void updateBookName(@Param("bookName") String bookName,
			@Param("bookId") int bookId);

	public void updateAuthor(@Param("authorName") String authorName,
			@Param("bookId") int bookId);

	public void updateOutPrice(@Param("outPrice") double outPrice,
			@Param("bookId") int bookId);

	public void updateInPrice(@Param("inPrice") double inPrice,
			@Param("bookId") int bookId);

	public void updatePress(@Param("press") String press,
			@Param("bookId") int bookId);

	public void updatePublishTime(@Param("publishTime") Date publishTime,
			@Param("bookId") int bookId);

	public void updateDescription(@Param("description") String description,
			@Param("bookId") int bookId);

	public void updateImagePath(@Param("imagePath") String imagePath,
			@Param("bookId") int bookId);

	public void updateStorageVolume(@Param("storageVolume") int storageVolume,
			@Param("bookId") int bookId);

	public void updateSaleVolume(@Param("saleVolume") int saleVolume, @Param("bookId") int bookId);

}
